﻿using UnityEngine;
using System.Collections;

public class Enemy : MonoBehaviour
{

		public float MoveSpeed;
		private bool isWalkingRight;


		// Use this for initialization
		void Start ()
		{
				isWalkingRight = true;
		}
	
		// Update is called once per frame
		void Update ()
		{
		Vector3 Movement = new Vector3 (10f, 0f, 0f);
				if (isWalkingRight) {
						Movement = new Vector3 (10f, 0f, 0f);
				} else {
						if (!isWalkingRight) {
								Movement = new Vector3 (-10f, 0f, 0f);
						}
				}

				transform.position += Movement * MoveSpeed * Time.deltaTime;
		}

		void OnCollisionEnter2D (Collision2D target)
		{
				if (target.gameObject.tag == "Player") {
						Destroy (target.gameObject);
				}
		}

		public void Turn (string direction)
		{
				if (direction.Equals ("left")) {
						isWalkingRight = false;	
				} else {
						isWalkingRight = true;
				}
		}
}
